﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Lithnet.GoogleApps;
using Lithnet.GoogleApps.ManagedObjects;
using Lithnet.GoogleApps.MA;
using Google.Apis.Auth.OAuth2;
using System.Collections.Generic;

namespace Lithnet.GoogleApps.MA.UnitTests
{
    public class UnitTestParameters : ManagementAgentParametersBase, IManagementAgentParameters
    {
        public UnitTestParameters()
            : base()
        {

            this.CustomerID = Properties.Settings.Default.CustomerID;
            this.ServiceAccountEmailAddress = Properties.Settings.Default.ServiceAccountEmailAddress;
            this.UserEmailAddress = Properties.Settings.Default.UserEmailAddress;
            this.KeyFilePath = Properties.Settings.Default.KeyFilePath;
            this.KeyFilePassword = Properties.Settings.Default.KeyFilePassword;
            this.PhonesAttributeFixedTypes = new List<string>() { "work", "home" };
            this.AddressesAttributeFixedTypes = new List<string>() { "work", "home" };
            this.ExternalIDsAttributeFixedTypes = new List<string>() { "customID1", "customID2" };
            this.IMsAttributeFixedTypes = new List<string>() { "work", "home" };
            this.OrganizationsAttributeFixedTypes = new List<string>() { "work", "home" };
            this.RelationsAttributeFixedTypes = new List<string>() { "manager", "other" };
            this.WebsitesAttributeFixedTypes = new List<string>() { "personal", "blog" };

        }

        public string CustomerID { get; set; }

        public string ServiceAccountEmailAddress { get; set; }

        public string GroupRegexFilter { get; set; }

        public string UserRegexFilter { get; set; }

        public string UserEmailAddress { get; set; }

        public string KeyFilePath { get; set; }

        public bool DoNotGenerateDelta { get; set; }

        public GoogleArrayMode PhonesAttributeFormat { get; set; }

        public IEnumerable<string> PhonesAttributeFixedTypes { get; set; }

        public GoogleArrayMode OrganizationsAttributeFormat { get; set; }

        public IEnumerable<string> OrganizationsAttributeFixedTypes { get; set; }

        public GoogleArrayMode IMsAttributeFormat { get; set; }

        public IEnumerable<string> IMsAttributeFixedTypes { get; set; }

        public GoogleArrayMode ExternalIDsAttributeFormat { get; set; }

        public IEnumerable<string> ExternalIDsAttributeFixedTypes { get; set; }

        public GoogleArrayMode RelationsAttributeFormat { get; set; }

        public IEnumerable<string> RelationsAttributeFixedTypes { get; set; }

        public GoogleArrayMode AddressesAttributeFormat { get; set; }

        public IEnumerable<string> AddressesAttributeFixedTypes { get; set; }

        public GoogleArrayMode WebsitesAttributeFormat { get; set; }

        public IEnumerable<string> WebsitesAttributeFixedTypes { get; set; }

        public bool ExcludeUserCreated { get; set; }

        public string KeyFilePassword { get; set; }

        public ServiceAccountCredential Credentials
        {
            get
            {
                return this.GetCredentials(
                    this.ServiceAccountEmailAddress,
                    this.UserEmailAddress,
                    this.GetCertificate(this.KeyFilePath, this.KeyFilePassword));
            }
        }
    }
}
